package com.core.zyyz.amc.modules.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.core.zyyz.constants.FunctionCode;
import com.core.zyyz.util.CodeMakerUtil;
import com.core.zyyz.util.PublicUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.core.zyyz.amc.modules.mapper.AmcCusPartnerInfoBMapper;
import com.core.zyyz.amc.modules.domain.AmcCusPartnerInfoB;
import com.core.zyyz.amc.modules.service.AmcCusPartnerInfoBService;

/**
 * 中介机构Service业务层处理
 *
 * @author lfs
 * @date 2024-12-12
 */
@Service
public class AmcCusPartnerInfoBServiceImpl implements AmcCusPartnerInfoBService
{
    @Autowired
    private AmcCusPartnerInfoBMapper amcCusPartnerInfoBMapper;

    /**
     * 查询中介机构
     *
     * @param partnerId 中介机构主键
     * @return 中介机构
     */
    @Override
    public AmcCusPartnerInfoB selectAmcCusPartnerInfoBByPartnerId(String partnerId)
    {
        return amcCusPartnerInfoBMapper.selectAmcCusPartnerInfoBByPartnerId(partnerId);
    }

    /**
     * 查询中介机构列表
     *
     * @param amcCusPartnerInfoB 中介机构
     * @return 中介机构
     */
    @Override
    public List<AmcCusPartnerInfoB> selectAmcCusPartnerInfoBList(AmcCusPartnerInfoB amcCusPartnerInfoB)
    {
        return amcCusPartnerInfoBMapper.selectAmcCusPartnerInfoBList(amcCusPartnerInfoB);
    }

    /**
     * 新增中介机构
     *
     * @param amcCusPartnerInfoB 中介机构
     * @return 结果
     */
    @Override
    public int insertAmcCusPartnerInfoB(AmcCusPartnerInfoB amcCusPartnerInfoB) {
        PublicUtil publicUtil = new PublicUtil();
//        publicUtil.addPublicMap(paramMap,"add");
        CodeMakerUtil cm = new CodeMakerUtil();
//        amcCusPartnerInfoB.setPartnerNumber(cm.bussCode(FunctionCode.AGENCY));
        amcCusPartnerInfoB.setPartnerId(UUID.randomUUID().toString());
        amcCusPartnerInfoB.setBaseConfigId("bc794998-699e-48c2-9ebe-7e88ec1da6f4");
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
        amcCusPartnerInfoB.setPartnerNumber(cm.createCode("PAR", df.format(new Date()),3));//生成合作伙伴编号
        return amcCusPartnerInfoBMapper.insertAmcCusPartnerInfoB(amcCusPartnerInfoB);
    }

    /**
     * 修改中介机构
     *
     * @param amcCusPartnerInfoB 中介机构
     * @return 结果
     */
    @Override
    public int updateAmcCusPartnerInfoB(AmcCusPartnerInfoB amcCusPartnerInfoB) {
        PublicUtil publicUtil = new PublicUtil();
//        publicUtil.addPublicMap(paramMap,null);
        return amcCusPartnerInfoBMapper.updateAmcCusPartnerInfoB(amcCusPartnerInfoB);
    }

    /**
     * 批量删除中介机构
     *
     * @param partnerIds 需要删除的中介机构主键
     * @return 结果
     */
    @Override
    public int deleteAmcCusPartnerInfoBByPartnerIds(String[] partnerIds)
    {
        return amcCusPartnerInfoBMapper.deleteAmcCusPartnerInfoBByPartnerIds(partnerIds);
    }

    /**
     * 删除中介机构信息
     *
     * @param partnerId 中介机构主键
     * @return 结果
     */
    @Override
    public int deleteAmcCusPartnerInfoBByPartnerId(String partnerId)
    {
        return amcCusPartnerInfoBMapper.deleteAmcCusPartnerInfoBByPartnerId(partnerId);
    }
}
